import request from "@/utils/request";
import { Base64 } from "js-base64";

// 人脸参数设置
export function faceConfigApi(params) {
  return request({
    url:
      "/cgi-bin/entry.cgi/event/face-config?timestamp=" + new Date().getTime(),
    method: "get",
    params,
  });
}
// 修改人脸参数设置
export function editFaceConfigApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/face-config",
    method: "put",
    data,
  });
}

// 获得用户信息
export function getSystemUserApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/system-user",
    method: "get",
  });
}

//确定
export function addFaceConfigApi(params) {
  return request({
    url: "/cgi-bin/entry.cgi/event/face-config",
    method: "put",
    params,
  });
}
// 获取基础设置
export function getSystemDeviceInfoApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/device-info",
    method: "get",
  });
}
//修改基础设置
export function editSystemDeviceInfoApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/device-info",
    method: "post",
    data,
  });
}

// 系统用户列表
export function getSystemUserListApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/login",
    method: "get",
  });
}

// 添加用户
export function addSystemUserApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/login/add",
    method: "put",
    data,
  });
}
// 修改用户
export function editSystemUserApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/login/modify",
    method: "put",
    data,
  });
}
// 删除用户
export function delSystemUserApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/login/delete",
    method: "put",
    data,
  });
}

//获取net设置
export function getSystemNetworkApi() {
  return request({
    url: "/cgi-bin/entry.cgi/network-ntp",
    method: "get",
  });
}
//获取时间设置
export function getSystemNetworkTimeApi() {
  return request({
    url: "/cgi-bin/entry.cgi/network-ntp/time",
    method: "get",
  });
}

// 获取时区列表
export function getTimezoneListApi() {
  return request({
    url: "/cgi-bin/entry.cgi/network-ntp/timezone-list",
    method: "get",
  });
}

// 获取UTC时区
export function getTimezoneApi() {
  return request({
    url: "/cgi-bin/entry.cgi/network-ntp/gettimezone",
    method: "get",
  });
}

// 保存UTC时区
export function setTimezoneApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/network-ntp/settimezone",
    method: "post",
    data,
  });
}

//保存net设置
export function editSystemNetworkApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/network-ntp",
    method: "put",
    data,
  });
}
//保存时间设置
export function editSystemNetworkTimeApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/network-ntp/time",
    method: "put",
    data,
  });
}

// 导出设备参数
export function systemExpotDbApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/export-db",
    method: "put",
  });
}
// 导出设备日志信息
export function systemExpotLogApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/export-log",
    method: "put",
  });
}

// 重启设备
export function systemRebootApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/reboot",
    method: "put",
  });
}
// 获取设备重启号
export function systemRemainSpaceApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/remain-space",
    method: "get",
  });
}

// 设备参数导入升级1-1
export function systemRemainImportApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/import-db",
    method: "put",
    data,
  });
}
// 设备参数导入升级1-2
export function systemRemainImportStartApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/import-db?start=1",
    method: "put",
  });
}

// 升级文件1-1
export function systemFirmwareUpgradeApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/firmware-upgrade?upload-type=resumable",
    method: "put",
  });
}
// 升级文件1-2 有文件
export function systemFirmwareUpgrade2Api(data, id) {
  return request({
    url: "/cgi-bin/entry.cgi/system/firmware-upgrade?id=" + id,
    method: "put",
    data,
  });
}
// 升级文件1-3
export function systemFirmwareUpgrade3Api() {
  return request({
    url: "/cgi-bin/entry.cgi/system/firmware-upgrade?start=995",
    method: "put",
  });
}

//恢复出厂设置1-1
export function systemStorageApi() {
  return request({
    url: "/cgi-bin/entry.cgi/storage/hdd-list",
    method: "put",
  });
}
//恢复出厂设置1-2
export function systemStorage2Api() {
  return request({
    url: "/cgi-bin/entry.cgi/system/pre-factory-reset",
    method: "put",
  });
}
//恢复出厂设置1-3
export function systemStorage3Api() {
  return request({
    url: "/cgi-bin/entry.cgi/system/factory-reset",
    method: "put",
  });
}

// 恢复出厂设置
export function resetDeviceApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/reset_device",
    method: "post",
    data,
  });
}

// 获取重启设备策略
export function getRebootStrategyApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/reboot-strategy",
    method: "get",
  });
}

// 修改重启设备策略
export function editRebootStrategyApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/reboot-strategy",
    method: "post",
    data,
  });
}

// 立马重启设备
export function rebootyApi() {
  return request({
    url: "/cgi-bin/entry.cgi/system/reboot",
    method: "post",
  });
}

// 系统状态查询
export function getSystemStatusApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/system-status",
    method: "get",
    data,
  });
}

// 获得识别参数
export function getFaceConfigsApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/face-config",
    method: "get",
    data,
  });
}

// 修改识别参数
export function editFaceConfigsApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/face-config",
    method: "post",
    data,
  });
}

// 获得识别模式
export function getAuthAggregateApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/auth-aggregate",
    method: "get",
    data,
  });
}

// 设置识别模式
export function setAuthAggregateApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/auth-aggregate",
    method: "put",
    data,
  });
}

// 获得算法参数
export function getRegisterConfigsApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/register-config",
    method: "get",
    data,
  });
}

// 修改算法参数
export function editRegisterConfigsApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/register-config",
    method: "post",
    data,
  });
}

// 算法参数恢复设置
export function faceConfigRestoreApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/face-config-restore",
    method: "post",
    data,
  });
}

// 注册参数恢复默认设置
export function registerConfigRestoreApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/register-config-restore",
    method: "post",
    data,
  });
}

// 获得抓拍参数
export function getSnapshotConfigApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/snapshot-config",
    method: "get",
    data,
  });
}
// 修改抓拍参数
export function editSnapshotConfigApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/snapshot-config",
    method: "post",
    data,
  });
}

// 固件初始化
export function firmwareUpgradeInitApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/firmware-upgrade?step=init",
    method: "post",
    data,
  });
}

// 固件开始更新
export function firmwareUpgradeApi(data) {
  return request({
    url: `/cgi-bin/entry.cgi/system/firmware-upgrade?upgrade=${data}`,
    method: "post",
  });
}

// 软件初始化
export function softwareUpgradeInitApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/software-upgrade?step=init",
    method: "post",
    data,
  });
}

// 软件开始更新
export function softwareUpgradeApi(data) {
  return request({
    url: `/cgi-bin/entry.cgi/system/software-upgrade?upgrade=${data}`,
    method: "post",
  });
}

// 算法初始化
export function algorithmUpgradeInitApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/system/algorithm-upgrade?step=init",
    method: "post",
    data,
  });
}

// 算法开始更新
export function algorithmUpgradeApi(data) {
  return request({
    url: `/cgi-bin/entry.cgi/system/algorithm-upgrade?upgrade=${data}`,
    method: "post",
  });
}

// 获取存储信息
export function getHddListApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/storage/hdd-list",
    method: "get",
    data,
  });
}

// 获取媒体存储路径信息
export function getStorageMediaFolderApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/storage/storage-media-folder",
    method: "get",
    data,
  });
}
// 修改媒体存储路径信息
export function editStorageMediaFolderApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/storage/storage-media-folder",
    method: "post",
    data,
  });
}

// 开始导出日志
export function exportLogApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/logs-export",
    method: "get",
    data,
  });
}
// 获取日志打包状态
export function getExportStatusApi(data) {
  return request({
    url: "/cgi-bin/entry.cgi/event/export-status",
    method: "get",
    data,
  });
}

// 软件上传文件
export function uploadSoftwareApi(id, data) {
  return request({
    url: `/cgi-bin/entry.cgi/system/software-upgrade?sliceId=${id}`,
    method: "post",
    data,
    headers: {
      "Content-Type": "text/plain",
    },
  });
}
// 软件开始合并
export function mergeSoftwareApi(id) {
  return request({
    url: `/cgi-bin/entry.cgi/system/software-upgrade?merge=${id}`,
    method: "post",
  });
}
// 软件开始检查
export function checkSoftwareApi(id) {
  return request({
    url: `/cgi-bin/entry.cgi/system/software-upgrade?check=${id}`,
    method: "post",
  });
}

// 算法上传文件
export function uploadAlgorithmApi(id, data) {
  return request({
    url: `/cgi-bin/entry.cgi/system/algorithm-upgrade?sliceId=${id}`,
    method: "post",
    data,
    headers: {
      "Content-Type": "text/plain",
    },
  });
}
// 算法开始合并
export function mergeAlgorithmeApi(id) {
  return request({
    url: `/cgi-bin/entry.cgi/system/algorithm-upgrade?merge=${id}`,
    method: "post",
  });
}
// 算法开始检查
export function checkAlgorithmApi(id) {
  return request({
    url: `/cgi-bin/entry.cgi/system/algorithm-upgrade?check=${id}`,
    method: "post",
  });
}

// 固件上传文件
export function uploadFirmwareApi(id, data) {
  return request({
    url: `/cgi-bin/entry.cgi/system/firmware-upgrade?sliceId=${id}`,
    method: "post",
    data,
    headers: {
      "Content-Type": "text/plain",
    },
  });
}
// 固件开始合并
export function mergeFirmwareApi(id) {
  return request({
    url: `/cgi-bin/entry.cgi/system/firmware-upgrade?merge=${id}`,
    method: "post",
  });
}
// 固件开始检查
export function checkFirmwareApi(id) {
  return request({
    url: `/cgi-bin/entry.cgi/system/firmware-upgrade?check=${id}`,
    method: "post",
  });
}

// 删除所有抓拍图片
export function delSnapShotAll(params) {
  return request({
    url: `/cgi-bin/entry.cgi/event/delete-snapshot-picture`,
    method: "delete",
  });
}

// 删除所有抓拍视频
export function delSnapShotRecord(params) {
  return request({
    url: `/cgi-bin/entry.cgi/event/delete-snapshot-video`,
    method: "delete",
  });
}


